//引入封装的axios
import request from '../util/request'
//引入url封装的js
import {KEY,API_24H,API_7D,API_CITY,API_NOW,API_AIR, API_INDICES} from './urlAPI'

//未来24小时天气预报请求
export const fetch24HourData = (locationID)=>{
    return request.get(API_24H,{
        params:{
            location: locationID,
            key:KEY,
        }
    })
}

//未来7日天气预报请求
export const fetch7DayData = (locationID)=>{
    return request.get(API_7D,{
        params:{
            location: locationID,
            key:KEY,
        }
    })
}

//城市天气预报请求
export const fetchCityData = (cityName)=>{
    return request.get(API_CITY,{
        params:{
            location: cityName,
            key:KEY,
        }
    })
}

//实时天气请求
export const fetchNowData = (locationID)=>{
    return request.get(API_NOW,{
        params:{
            location: locationID,
            key:KEY,
        }
    })
}

// //实时空气质量请求
// export const fetchAirData = (latitude,longitude)=>{
//     return request.get(API_AIR+"/"+latitude+"/"+longitude,{
//         params:{
//             // location: ,
//             key:KEY,
//         }
//     })
// }

//实时空气质量请求
export const fetchAirData = (latitude,longitude)=>{
    return request.get(API_AIR+`/${latitude}/${longitude}`,{
        params:{
            // location: ,
            key:KEY,
        }
    })
}
//天气指数预报请求
export const fetchIndicesData = (locationID,type)=>{
    return request.get(API_INDICES,{
        params:{
            location: locationID,
            type:type,
            key:KEY,
        }
    })
}